define(function (require, exports, module) {
	var Grid = require("grid");
	var Dialog = require("dialog");
	
    var instance = {
    	renderGrid: function (widget) {
        	var roomGrid = new Grid({
                parentNode: "#J-roomGrid", 
                model : {
                    id:"roomGrid",
                    head : {
					items : [ {
							id : "roomAdd",
							type : "button",
							text : "增加房间",
							handler : function() {
								widget.handler.addRoomEvent(widget);
							}
						} ]
					},
                    columns : [{
        				name:"room.orgBuilding.name",
        				label:"楼宇",
        				format:function(value,row){
        					if(row.pkRoomRegister){
        						return value;
        					}else{
        						return row.orgBuilding.name;
        					}
        				}
        			},{
        				name:"room.roomType.name",
        				label:"房型",
        				format:function(value,row){
        					if(row.pkRoomRegister){
        						return value;
        					}else{
        						return row.roomType.name;
        					}
        				}
        			},{
        				name:"room.status.value",
        				label:"房间状态",
        				format:function(value,row){
        					if(row.pkRoomRegister){
        						return value;
        					}else{
        						return row.status.value;
        					}
        				}
        			},{
        				name:"room.code",
        				label:"预定房间",
        				format:function(value,row){
        					if(value||row.pkRoomRegister){
        						return value;
        					}else{
        						return row.code;
        					}
        				}
        			},{
        				name:"operate",
        				label:"操作",
        				format:"button",
        				formatparams:[{
        					id:"del",
        					text: "删除",
        					show:true,
        					handler:function(index,data,rowEle){
        						Dialog.confirm({
        							title:"提示",
        							content:"确定删除"+(data.room?data.room.code:data.code)+"房间吗？",
        							confirm:function(){
        								roomGrid.remove(index);
        								widget.set("deleteRoom",true);
        							}
        						});
//        						Dialog.confirm({
//        							title:"提示",
//        							content:"确定删除"+(data.pkRoomRegister?data.room.code:data.code)+"房间吗？",
//        							confirm:function(){
//        								widget.service.ridRoom({
//                							"pkGroupReserve":widget.get("data").groupReserve.pkGroupReserve,
//                							"pkRoomRegister":data.pkRoomRegister
//                						},function(ret){
//                							widget.refreshRoomGrid(widget);
//                						})
//        							}
//        						});
        					}
        				}]
        			}]
                }
            });
            widget.set("roomGrid",roomGrid);
        }
    };
    module.exports = instance;
});